package string;

public class StringBuilderDemo {
    public static void main(String[] args) {
        String str = "好好学习java";

        StringBuilder builder = new StringBuilder(str);


        //添加
        builder.append(",为了找个好工作");
        System.out.println(str);
        System.out.println(builder);



        // 替换
        builder.replace(9,16,"就是为了改变世界");
        System.out.println(builder);


        //删除
        builder.delete(8,17);
        System.out.println(builder);

        //插入制定位置
        builder.insert(0,"活者");
        System.out.println(builder);

        //反转  倒着输出
        builder.reverse();
        System.out.println(builder);

        //StringBuilder只是修改字符串的工具 并非String本身
        //取出修改字符

        String line = builder.toString();
        System.out.println(line);



    }
}
